PDH Data Types

All PDH string structures are shown as  TCHAR , meaning that both Unicode and ANSI string structures are supported. Internally, the native or preferred code path inside the PDH is the Unicode string format, since it is built only for Windows NT. An ANSI version of each function is provided for those functions that have string arguments. They are, however, slightly less efficient since they must convert the ANSI string arguments to Unicode arguments before calling the Unicode version of the function.

The string data types expected are determined by the Unicode symbol when the application is compiled. If Unicode is defined, then the Unicode or wide character strings are expected. If the symbol is undefined, then the 8-bit or ANSI character strings are expected.

Data Type

Description

HQUERY

Handle to a query (HANDLE).

HCOUNTER

Handle to a counter. PDH maintains the linkage between counters and queries.

PDH_STATUS

LONG PDH status value.

 

Unless otherwise specified, all functions return a Win32 status value of ERROR_SUCCESS if the function completes successfully or a PDH error status value defined in the PDHMSG.H include file.

For data collection and formatting functions it is important to remember that the return value of the function indicates the success or error of the function call and not necessarily that of the counter data. Always check the CStatus field of the counter value returned to ensure that the data returned is valid before you use it. If the value of the CStatus field does not indicate success, do not use the data.